package com.color.admin.system.entity;


import com.color.admin.common.core.constant.Constant;
import com.color.admin.common.core.constant.ConstantData;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.v3.oas.annotations.media.Schema;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * @author HaiQiu
 * @date 2022/1/18
 */
@Entity
@Table(name = ConstantData.DEPT_DICT_DETAIL, schema = ConstantData.SOURCE)
public class SysDictDetail extends BaseEntity implements Serializable {

    @Id
    @Column(name = "id")
    @GeneratedValue(generator = "id")
    @GenericGenerator(name = "id", strategy = "org.hibernate.id.UUIDGenerator")
    @NotBlank(message = "ID"+ Constant.NOT_EMPTY,groups = update.class)
    private String id;

    @Basic
    @Column(name = "label")
    @Schema(example = "男", description = "字典标签")
    @NotBlank(message = "字典标签"+Constant.NOT_EMPTY)
    @Size(min = 1,max = 20,message = "字典标签长度只能在1-20个字符")
    private String label;

    @Basic
    @Column(name = "value")
    @Schema(example = "0", description = "字典值")
    @NotBlank(message = "字典值"+Constant.NOT_EMPTY)
    @Size(min = 1,max = 50,message = "字典值长度只能在1-50个字符")
    private String value;

    @JoinColumn(name = "dict_id")
    @JsonIgnoreProperties(value = { "hibernateLazyInitializer"})
    @ManyToOne(fetch=FetchType.LAZY)
    @Schema(description = "字典目录ID")
    private SysDict dict;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public SysDict getDict() {
        return dict;
    }

    public void setDict(SysDict dict) {
        this.dict = dict;
    }

}
